package com.skydonkey.service.impl;

import com.skydonkey.dao.AccountMapper;
import com.skydonkey.pojo.po.Account;
import com.skydonkey.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    AccountMapper accountMapper;

    @Override
    public Account findByUid(Long uid) {
        return accountMapper.findById(uid);
    }

    @Override
    public Account findByUsername(String username) {
        return accountMapper.findByUsername(username);
    }

    @Override
    public List<Account> findAll() {
        return accountMapper.findAll();
    }

    @Override
    public boolean createAccount(Account account) {
        int insert = accountMapper.insert(account);
        return insert == 1;
    }


    @Override
    public boolean deleteAccount(Long uid) {
        int delete = accountMapper.deleteById(uid);
        return delete == 1;
    }
}
